\section*{\large Robot Node}
\begin{normalsize}

The \emph{Robot node} implements all the functions needed to interact with the robot sensors and actuators. Three callbacks listen to the gyroscope, ultrasonic and intensity sensor status and a fourth callback listens to the joints state.

\bigskip
\noindent A set of ``low level'' functions implements the basic movements for the robot:

\begin{itemize}
	\item \textbf{rotate()};
	\item \textbf{goStraight()};
	\item \textbf{rotateHead()};
\end{itemize}

The rotate function and the goStraight function accept a boolean function as parameter, so, for example we can say goStraight(overTheLine) and the robot goes straight until the ``overTheLine'' condition becomes true.

\bigskip
\noindent An higher layer of functions gives a solution to non-trivial tasks:

\begin{itemize}
	\item \textbf{changeOrientation()};
	\item \textbf{getNeighbors()};
	\item \textbf{moveToCell()};
\end{itemize}

All these functions are transparent to the user of the Robot node thanks to two services that the node advertises:

\begin{itemize}
	\item \textbf{move\_to\_cell service} receives an integer in the range [0, 3] and makes the robot change its location moving to the north (0), east (1), south (2) or west (3) cell. At the end of the procedure it returns true or false according to the movement result;
	\item \textbf{get\_neighbors service} makes the robot look around for obstacles and returns a four int vector, ordered from north to west. The vector contains 1 for the occupied cells and 0 for the free cells;
\end{itemize}

\noindent An interesting property we discovered is a sort of \textbf{regenerative property}. If we make these two assumptions:

\begin{enumerate}
\item each time the robot reaches a white line it calibrates its orientation;
\item than it advances by a distance equal to half the length of the cell.
\end{enumerate}

\noindent we can notice that every time the robot makes a 90 degrees trajectory, it reaches exactly the center of the last cell, disregarding of the starting robot position. For a better explanation of this property refer to the figure \ref{fig:regproperty} where the robot, starting far from the start cell center, reaches the center of the destination cell by two cell changes.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.5]{./images/property.pdf}
\caption{ Regenerative property. \label{fig:regproperty}}
\end{figure}

\end{normalsize}